import { useState } from "react";
import Cart from "./components/Cart";
import NavBar from "./components/NavBar";

/**
 * 保存state的组件应该亦是更新state的组件
 */

function App() {
  const [cartItems, setCartItems] = useState(["Product1", "Product2"]);

  const onClear = () => {
    setCartItems([]);
  };

  return (
    <div>
      <NavBar cartItemsCount={cartItems.length} />
      <Cart cartItems={cartItems} onClear={onClear} />
    </div>
  );
}

export default App;
